<template>
  <!-- 组件列表 -->
  <div class="box">
    <div class="item" v-for="(widget, index) in widgetList" :key="index" @mousedown="mousedown($event, widget)"
      draggable="true">
      <!-- 特殊组件提示 -->
      <div v-if="index == 5" class="tips">
        <i class="el-icon-warning"></i>
        <div class="tipsCon">
          <div>1. 一个栏目绑定四个影片。</div>
        </div>
      </div>
      <!-- <span :class="widget.icon"></span> -->
      <img :src="require('@/assets/icon/' + widget.icon)">
      <p>{{ widget.label }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "widgetList",
  props: {
    widgetList: {//组件列表
      type: Array,
      required: true,
      default: () => []
    },
  },
  data() {
    return {}
  },
  methods: {
    // 鼠标按下事件(原生事件mousedown)
    mousedown(e, widget) {
      this.$emit('onWidgetMouseDown', e, widget)
    }
  },
}
</script>

<style lang="scss" scoped>
.box {
  margin-top: 10px;

  .item {
    width: 60px;
    height: 80px;
    display: flex;
    align-items: center;
    flex-direction: column;
    font-size: 14px;
    text-align: center;
    color: #666;
    float: left;
    margin: 10px;
    margin-bottom: 0;
    border-radius: 6px;
    cursor: pointer;
    position: relative;

    &:hover {
      background: #E6F0FE;
    }

    .tips {
      color: #e6a23c;
      position: absolute;
      right: 0;

      &:hover {
        .tipsCon {
          display: block;
        }
      }

      .tipsCon {
        display: none;
        background: #fff;
        width: 195px;
        padding: 2px 5px;
        border: 1px solid #cdcdcd;
        position: absolute;
        right: 0;
        z-index: 9;
      }
    }

    span {
      font-size: 50px;
      margin-bottom: 8px;
      color: #999;
    }

    p {
      margin: 0;
      font-size: 12px;
    }
  }
}
</style>